Skip to content

Commit f8f9295

Browse files
authored
Merge pull request #13704 from dotty-staging/fix-13701
Alt fix for #13701
2 parents 1e38974 + e0c33ec commit f8f9295

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ object SymDenotations {
9393
if (myFlags.is(Trait)) NoInitsInterface & bodyFlags // no parents are initialized from a trait
9494
else NoInits & bodyFlags & parentFlags)
9595

96-
private def isCurrent(fs: FlagSet) =
97-
fs <= (
98-
if (myInfo.isInstanceOf[SymbolLoader]) FromStartFlags
99-
else AfterLoadFlags)
96+
def isCurrent(fs: FlagSet)(using Context): Boolean =
97+
def knownFlags(info: Type): FlagSet = info match
98+
case _: SymbolLoader | _: ModuleCompleter => FromStartFlags
99+
case _ => AfterLoadFlags
100+
!myInfo.isInstanceOf[LazyType] || fs <= knownFlags(myInfo)
100101

101102
final def relevantFlagsFor(fs: FlagSet)(using Context) =
102103
if (isCurrent(fs)) myFlags else flags
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package dotty.tools.repl
2+
3+
import org.junit.Assert._
4+
import org.junit.Test
5+
6+
class JavaDefinedTests extends ReplTest {
7+
@Test def typeOfJavaDefinedString = fromInitialState { implicit s =>
8+
run("String")
9+
assertTrue(storedOutput().contains("Java defined class String is not a value"))
10+
}
11+
12+
@Test def typeOfJavaDefinedClass = fromInitialState { implicit s =>
13+
run("Class")
14+
assertTrue(storedOutput().contains("Java defined class Class is not a value"))
15+
}
16+
}

tests/neg/i13701.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@main def Test() = String // error
2+

0 commit comments

Comments
 (0)