Skip to content

Commit 0bd34f8

Browse files
authored
Merge pull request scala#9653 from dwijnand/fix-prefixAlign
Fix prefixAligns, avoid spurious outer test warnings on patdep types
2 parents c7debd6 + 531ca66 commit 0bd34f8

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging {
393393
case TypeRef(pre, _, _) if !pre.isStable => // e.g. _: Outer#Inner
394394
false
395395
case TypeRef(pre, sym, args) =>
396-
val testedBinderClass = testedBinder.info.upperBound.typeSymbol
397-
// alternatively..... = testedBinder.info.baseClasses.find(_.isClass).getOrElse(NoSymbol)
396+
val testedBinderClass = testedBinder.info.baseClasses.find { sym =>
397+
sym.isClass && !sym.isRefinementClass
398+
}.getOrElse(NoSymbol)
398399
val testedBinderType = testedBinder.info.baseType(testedBinderClass)
399400

400401
val testedPrefixIsExpectedTypePrefix = pre =:= testedBinderType.prefix

test/files/pos/t12392.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Werror
12
import scala.reflect.api.Universe
23

34
object Test {

test/files/pos/t12398.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// scalac: -Werror
2+
import scala.reflect.api.Universe
3+
4+
object Test {
5+
type SingletonUniverse = Universe with Singleton
6+
7+
def foo[U <: SingletonUniverse](u: U)(typ: u.Type): List[u.Annotation] = typ match {
8+
case t: u.AnnotatedTypeApi => t.annotations // was: "The outer reference in this type test cannot be checked at run time."
9+
case _ => Nil
10+
}
11+
}

test/files/pos/t12398b.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// scalac: -Werror
2+
import scala.reflect.api.Universe
3+
4+
object Test {
5+
type SingletonUniverse = Universe with Singleton
6+
7+
def foo[U <: SingletonUniverse](u: U)(typ: U#Type): List[U#Annotation] = typ match {
8+
case t: U#AnnotatedTypeApi => t.annotations // as a comparison, this wasn't emitting a warning
9+
case _ => Nil
10+
}
11+
}

0 commit comments

Comments
 (0)