Skip to content

Commit 536a751

Browse files
author
builduser
committed
Merged branch idea251.release into idea251.x
2 parents ee0bc24 + 132a2ac commit 536a751

File tree

8 files changed

+42
-6
lines changed

8 files changed

+42
-6
lines changed

scala/compiler-integration/src/org/jetbrains/plugins/scala/compiler/highlighting/ExternalHighlightersService.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import org.jetbrains.plugins.scala.compiler.highlighting.ExternalHighlighting.Ra
3131
import org.jetbrains.plugins.scala.editor.DocumentExt
3232
import org.jetbrains.plugins.scala.extensions.{IteratorExt, ObjectExt, Parent, PsiElementExt, executeOnPooledThread, invokeLater}
3333
import org.jetbrains.plugins.scala.lang.psi.api.base.{ScReference, ScStableCodeReference}
34-
import org.jetbrains.plugins.scala.lang.psi.api.expr.ScMethodCall
34+
import org.jetbrains.plugins.scala.lang.psi.api.expr.MethodInvocation
3535
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.imports.usages.ImportUsed
3636
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.imports.usages.ImportUsed.UnusedImportReportedByCompilerKey
3737
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.imports.{ScImportExpr, ScImportOrExportStmt, ScImportSelector}
@@ -83,7 +83,7 @@ private final class ExternalHighlightersService(project: Project) { self =>
8383
psiFile
8484
.depthFirst(_.getTextRange.contains(range)) // Optimized iteration
8585
.filter(_.getTextRange == range)
86-
.find(e => e.is[ScMethodCall, ScStableCodeReference])
86+
.find(e => e.is[MethodInvocation, ScStableCodeReference])
8787
.foreach { e =>
8888
// Skip if the same value already exists
8989
if (!CompilerType(e).contains(tpe)) {

scala/compiler-plugin/scala-2.12/src/CompilerPlugin.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class CompilerPlugin(val global: Global) extends Plugin {
3939
private val transformer = new Transformer() {
4040
override def transform(tree: Tree): Tree = {
4141
tree.attachments.get[analyzer.MacroExpansionAttachment] match {
42-
case Some(analyzer.MacroExpansionAttachment(expandee, expanded: Tree)) if isWhiteboxMacro(global)(expandee.symbol) && expanded.tpe != null =>
42+
case Some(analyzer.MacroExpansionAttachment(expandee, expanded: Tree)) if isWhiteboxMacro(global)(expandee.symbol) =>
4343
// If there's a type mismatch, the type checker replaces the tree type with an ErrorType (see TyperErrorGen.issueError)
44-
val tpe = if (expanded.tpe.isError) typer.typed(expandee).tpe else expanded.tpe
44+
val tpe = if (tree.tpe.isError) typer.typed(expandee).tpe else tree.tpe
4545
val s = LiteralTypePattern.replaceAllIn(tpe.toString, _.group(1))
4646
// echo is not binary compatible between 2.13.11 and 2.13.12 (overloading vs default argument)
4747
reporter.info(expandee.pos, TypePrefix + s + TypeSuffix, force = true)

scala/compiler-plugin/scala-2.12/test/CompilerPluginTest.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class CompilerPluginTest {
5454
usage("val v = Macros.id(Set(1, 2, 3))"))(
5555
info("Macros.id(Set(1, 2, 3))", tpe("scala.collection.immutable.Set[Int]")))
5656

57+
// Expected type
58+
59+
@Test def expectedType(): Unit = assertMessagesAre(Id,
60+
usage("val v = Macros.id(123): Int"))(
61+
info("Macros.id(123)", tpe("123")))
62+
5763
// Multiple
5864

5965
@Test def multipleTypes(): Unit = assertMessagesAre(Id,

scala/compiler-plugin/scala-2.13/src/CompilerPlugin.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class CompilerPlugin(val global: Global) extends Plugin {
3939
private val transformer = new Transformer() {
4040
override def transform(tree: Tree): Tree = {
4141
tree.attachments.get[analyzer.MacroExpansionAttachment] match {
42-
case Some(analyzer.MacroExpansionAttachment(expandee, expanded: Tree)) if isWhiteboxMacro(global)(expandee.symbol) && expanded.tpe != null =>
42+
case Some(analyzer.MacroExpansionAttachment(expandee, expanded: Tree)) if isWhiteboxMacro(global)(expandee.symbol) =>
4343
// If there's a type mismatch, the type checker replaces the tree type with an ErrorType (see TyperErrorGen.issueError)
44-
val tpe = if (expanded.tpe.isError) typer.typed(expandee).tpe else expanded.tpe
44+
val tpe = if (tree.tpe.isError) typer.typed(expandee).tpe else tree.tpe
4545
val s = LiteralTypePattern.replaceAllIn(tpe.toString, _.group(1))
4646
// echo is not binary compatible between 2.13.11 and 2.13.12 (overloading vs default argument)
4747
reporter.info(expandee.pos, TypePrefix + s + TypeSuffix, force = true)

scala/compiler-plugin/scala-2.13/test/CompilerPluginTest.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class CompilerPluginTest {
5454
usage("val v = Macros.id(Set(1, 2, 3))"))(
5555
info("Macros.id(Set(1, 2, 3))", tpe("scala.collection.immutable.Set[Int]")))
5656

57+
// Expected type
58+
59+
@Test def expectedType(): Unit = assertMessagesAre(Id,
60+
usage("val v = Macros.id(123): Int"))(
61+
info("Macros.id(123)", tpe("123")))
62+
5763
// Multiple
5864

5965
@Test def multipleTypes(): Unit = assertMessagesAre(Id,

scala/compiler-plugin/scala-3.3/test/CompilerPluginTest.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class CompilerPluginTest {
4646
"val _ = id(Set(1, 2, 3))")(
4747
info("id(Set(1, 2, 3))", tpe("_root_.scala.collection.immutable.Set[_root_.scala.Int]")))
4848

49+
// Expected type
50+
51+
@Test def expectedType(): Unit = assertMessagesAre(Id,
52+
"val _ = id(123): Int")(
53+
info("id(123)", tpe("123")))
54+
4955
// Multiple
5056

5157
@Test def multipleTypes(): Unit = assertMessagesAre(Id,

scala/decompiler/test/org/jetbrains/plugins/scala/decompiler/Main.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import java.nio.file.{Files, Path, Paths}
55
import java.util.jar.JarInputStream
66
import scala.util.chaining.scalaUtilChainingOps
77

8+
/**
9+
* A helper to quickly assess the effect of non-trivial ScalaSigPrinter modifications.
10+
*
11+
* Although the corresponding code is tested both by the DecompilerTest (unit) and TextToTextTestBase (integration) tests,
12+
* the former rely on predefined test cases, while the latter only ensure correctness, without a diff.
13+
*
14+
* You may only want to use this if you intend to modify the decompiler implementation extensively.
15+
* First, you should run the TextToTextTestBase tests to download the Ivy artifacts and also to adjust the OutputDir.
16+
*/
817
object Main {
918
sealed abstract class Mode
1019
object Mode {

scala/tasty-reader/test/Main.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import java.nio.file.{Files, Path, Paths}
55
import java.util.jar.JarInputStream
66
import scala.util.chaining.scalaUtilChainingOps
77

8+
/**
9+
* A helper to quickly assess the effect of non-trivial TreePrinter modifications.
10+
*
11+
* Although the corresponding code is tested both by the DecompilerTest (unit) and TextToTextTestBase (integration) tests,
12+
* the former rely on predefined test cases, while the latter only ensure correctness, without a diff.
13+
*
14+
* You may only want to use this if you intend to modify the decompiler implementation extensively.
15+
* First, you should run the TextToTextTestBase tests to download the Ivy artifacts and also to adjust the OutputDir.
16+
*/
817
object Main {
918
enum Mode { case Parse, Test, Benchmark }
1019

0 commit comments

Comments
 (0)