Skip to content

Commit 974a7c1

Browse files
committed
fix nested @unchecked
1 parent 183be33 commit 974a7c1

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ object Trees {
805805
def unforced: AnyRef
806806
protected def force(x: AnyRef): Unit
807807
def forceIfLazy(implicit ctx: Context): T = unforced match {
808-
case lzy: Lazy[T] =>
808+
case lzy: Lazy[T @unchecked] =>
809809
val x = lzy.complete
810810
force(x)
811811
x

compiler/src/dotty/tools/dotc/transform/IsInstanceOfChecker.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ object Checkable {
6464

6565
def replaceBinderMap(implicit ctx: Context) = new TypeMap {
6666
def apply(tp: Type) = tp match {
67-
case tref: TypeRef if !tref.typeSymbol.isClass && tref.symbol.is(Case) => WildcardType
67+
case tref: TypeRef
68+
if !tref.typeSymbol.isClass && tref.symbol.is(Case) => WildcardType
69+
case AnnotatedType(_, annot)
70+
if annot.symbol == defn.UncheckedAnnot => WildcardType
6871
case _ => mapOver(tp)
6972
}
7073
}

tests/neg-custom-args/isInstanceOf/t2755.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,7 @@ object Test {
5555
println(f3(Array(1L)))
5656
println(f3(null))
5757
}
58+
59+
def foo(x: Any): Boolean =
60+
x.isInstanceOf[List[String]] // error
5861
}

0 commit comments

Comments
 (0)