Skip to content

Commit

Permalink
Merge pull request #10760 from lrytz/t12987
Browse files Browse the repository at this point in the history
Normalize reference to undet param in stabilizer
  • Loading branch information
lrytz committed May 8, 2024
2 parents ccdcde3 + e918307 commit ab41073
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -5524,7 +5524,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
context.pendingStabilizers ::= vdef
qual.changeOwner(context.owner -> vsym)
val newQual = Ident(vsym) setType singleType(NoPrefix, vsym) setPos qual.pos.focus
return typedSelect(tree, newQual, name)
return typedSelect(tree, newQual, name).modifyType(_.map {
// very specific fix for scala/bug#12987 (details in the ticket)
case t: AliasTypeRef if t.pre.termSymbol == vsym && context.undetparams.contains(t.normalize.typeSymbol) =>
t.normalize
case t => t
})
}

val tree1 = tree match {
Expand Down
30 changes: 30 additions & 0 deletions test/files/pos/t12987.scala
@@ -0,0 +1,30 @@
object typeMember {
class Foo {
type FT
class I
def m(b: FT, o: Option[I]): Int = 0
}

object Test {
def f[T]: Foo { type FT = T } = ???
def t = {
val b: Any = ???
f.m(b, None)
}
}
}

object typeParam {
class Foo[FT] {
class I
def m(b: FT, o: Option[I]): Int = 0
}

object Test {
def f[T]: Foo[T] = ???
def t = {
val b: Any = ???
f.m(b, None)
}
}
}

0 comments on commit ab41073

Please sign in to comment.