Skip to content

Fix REPL for Java defined types #13701

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ object Checking {

def checkValue(tree: Tree)(using Context): Unit =
val sym = tree.tpe.termSymbol
sym.ensureCompleted()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed.

if sym.is(Flags.Package) || sym.isAllOf(Flags.JavaModule) && !ctx.isJava then
report.error(JavaSymbolIsNotAValue(sym), tree.srcPos)

Expand Down
16 changes: 16 additions & 0 deletions compiler/test/dotty/tools/repl/JavaDefinedTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dotty.tools.repl

import org.junit.Assert._
import org.junit.Test

class JavaDefinedTests extends ReplTest {
@Test def typeOfJavaDefinedString = fromInitialState { implicit s =>
run("String")
assertTrue(storedOutput().contains("Java defined class String is not a value"))
}

@Test def typeOfJavaDefinedClass = fromInitialState { implicit s =>
run("Class")
assertTrue(storedOutput().contains("Java defined class Class is not a value"))
}
}