scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

stale symbol in typeref (typeRef should rebind type aliases) #3731

Closed scabug closed 13 years ago

scabug commented 13 years ago
object Test{
  trait ZW[S]{type T}
  def ZipWith[S, M <: ZW[S]]: M#T = error("ZW")
  def meh[A] = ZipWith[A, ZW[A]{type T=Stream[A]}] // T-Def

  meh[Int]: Stream[Int]
}

scala-2.8.0-final says:

error: type mismatch;
 found   : Test.ZWSI-9200[IntSI-4392]{type TSI-11267 = StreamSI-3223[IntSI-4392]}#TSI-11016
 required: StreamSI-3223[IntSI-4392]
  meh[Int]: Stream[Int]
     ^

This should type check, though.

Rough explanation: after the prefix in the typeref M#T is updated to reflect the instantiation of the type arguments in meh[Int], the symbol that is used to refer to T is stale: it's still the symbol defined in the line marked with // T-Def

However, it should refer to the new symbol (not visible in the source code) that has A instantiated to Int.

scabug commented 13 years ago

Imported From: https://issues.scala-lang.org/browse/SI-3731?orig=1 Reporter: @adriaanm

scabug commented 13 years ago

@adriaanm said: (In r23010) closes #1569, #3731: refactored dependent method types to get rid of debruijn indices and use singleton types instead.

this is the core of the dependent types refactoring, no implicit or inference changes

(one baffling discovery: resultType should drop annotations that don't subclass TypeConstraint, even in the trivial case... wow -- thanks to Tiark for helping me figure it out on a terrace in Barcelona TODO: probably need a more principled approach to the propagation of plugin type-annotations)

review by odersky

scabug commented 13 years ago

@adriaanm said: (In r23011) part 2 of the dependent method refactoring: improved interaction with implicit search (needed for oopsla paper)

more to come in this area, see e.g. #3346 (stanford edsl stuff)

reopens SI-13, which wasn't fixed properly before imo, anyway (have a look at -Xprint:typer output before this commit: a type that's not expressible in surface syntax is inferred -- also removed duplicate test file)

closes #3731: co-evolve type alias type symbols when their rhs is updated and they are referenced by type selections (see typemap)

review by odersky