Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] Under -Xsource:2.13, don't GLB binders of type patterns, use the type directly #10298

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ trait MatchTranslation {
case TypeBound(tpe) => tpe
case tree => tree.tpe
}
def glbWith(other: Type) = glb(tpe :: other :: Nil).normalize
def glbWith(other: Type) = if (currentRun.isScala213) other else glb(tpe :: other :: Nil).normalize

object SymbolAndTypeBound {
def unapply(tree: Tree): Option[(Symbol, Type)] = tree match {
Expand Down
2 changes: 2 additions & 0 deletions test/files/run/t12702.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
warning: one feature warning; re-run with -feature for details
IOS
19 changes: 19 additions & 0 deletions test/files/run/t12702.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// scalac: -Xsource:2.13

object Test {
trait MFSS[X <: MFSS[_]]
trait CS extends MFSS[CS]
trait MFI { type ST }
case class MFSD[S](mFI: MFI {type ST = S})
case object IOS extends MFI { type ST = CS }
type SD = MFSD[S] forSome {
type S <: MFSS[S]
}
def bad(sd: SD) = sd.mFI match {
case ios: IOS.type => println(ios)
}
def main(args: Array[String]): Unit = {
val x = MFSD(IOS)
bad(x)
}
}
29 changes: 29 additions & 0 deletions test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,33 @@ class SymbolTableTest {
import symbolTable._
assert(NoSymbol.outerClass == NoSymbol)
}

@Test def t12702_glb(): Unit = {
import symbolTable._
import SymbolTableTest.t12702._
val t1 = typeOf[IOS.type]
val t2 = {
val sd = typeOf[SD]
sd.memberType(sd.member(TermName("mFI"))).finalResultType
}
// t1: Test.IOS.type
// t2: Test.MFI{type +ST = S}

// Ends up in `throw GlbFailure` in glb => Null
assertTrue(definitions.NullTpe =:= glb(t1 :: t2 :: Nil))
}
}

object SymbolTableTest {
object t12702 {
import scala.language.existentials
trait MFSS[X <: MFSS[_]]
trait CS extends MFSS[CS]
trait MFI { type ST }
case class MFSD[S](mFI: MFI {type ST = S})
case object IOS extends MFI { type ST = CS }
type SD = MFSD[S] forSome {
type S <: MFSS[S]
}
}
}