|
[#836] |
project: compiler |
priority: low |
category: feature |
|
submitter |
assigned to |
status |
date submitted |
|
Nikolay |
Martin |
fixed |
2006-11-24 16:01:07.0 |
subject |
[contrib #254] derive from abstract types |
code |
<code>
abstract class Obj { type S }
class ObjImpl extends Obj { type S = String }
abstract class A {
type MyObj <: Obj
type S = MyObj#S
val any: Any = 0
val some: S = any // compiles => type X is set to scala.Any
}
class B extends A {
type MyObj = ObjImpl
val myString: S = "hello"
val realString: String = myString // error: type missmatch
}
</code> |
what happened |
$ scala -version
Scala code runner version 2.2.0.9262.20061114-203804 -- (c) 2002-2006 LAMP/EPFL
$ scalac tests/Bug4.scala
tests/Bug4.scala:15 error: type mismatch;
found : scala.Any
required: java.lang.String
val realString: String = myString
^
one error found
|
what expected |
The type S = MyObj#S should not be set to scala.Any. Such a type definition should either be forbidden or it's definition should be defered until the type of MyObj is known. This would make S abstract as long as MyObj is an abstract type. |
[back to overview] |