Skip to content
Merged
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 build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ lazy val testSources = crossProject(JSPlatform, JVMPlatform)
.settings(
publish / skip := true,
scalacOptions += "-Werror",
scalacOptions += "-preview",
javacOptions += "-parameters",
)
.dependsOn(scala2TestSources)
Expand Down
1 change: 1 addition & 0 deletions tasty-query/shared/src/main/scala/tastyquery/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private[tastyquery] object Flags:
val Infix: Flag = newFlag("Infix")
val Inline: Flag = newFlag("Inline")
val InlineProxy: Flag = newFlag("InlineProxy")
val Into: Flag = newFlag("Into")
val JavaDefined: Flag = newFlag("JavaDefined")
val Lazy: Flag = newFlag("Lazy")
val Local: Flag = newFlag("Local")
Expand Down
3 changes: 3 additions & 0 deletions tasty-query/shared/src/main/scala/tastyquery/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,9 @@ object Symbols {

final def isOpaqueTypeAlias: Boolean = flags.is(Opaque)

/** Is this a type with the `into` modifier? */
final def isIntoType: Boolean = flags.is(Into)

private[tastyquery] final def topLevelRef: TypeRef =
require(owner.isPackage, s"Cannot construct a topLevelRef for non-top-level symbol $this")
TypeRef(owner.asPackage.packageRef, this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ import scala.annotation.switch
* EXPORTED -- An export forwarder
* OPEN -- an open class
* INVISIBLE -- invisible during typechecking
* INTO -- has the `into` modifier
* Annotation
*
* Variance = STABLE -- invariant
Expand Down Expand Up @@ -489,6 +490,7 @@ private[tasties] object TastyFormat:
final val INVISIBLE = 44
final val EMPTYCLAUSE = 45
final val SPLITCLAUSE = 46
final val INTO = 49

// Cat. 2: tag Nat

Expand Down Expand Up @@ -614,7 +616,7 @@ private[tasties] object TastyFormat:

/** Useful for debugging */
def isLegalTag(tag: Int): Boolean =
firstSimpleTreeTag <= tag && tag <= SPLITCLAUSE
firstSimpleTreeTag <= tag && tag <= INTO
|| firstNatTreeTag <= tag && tag <= RENAMED
|| firstASTTreeTag <= tag && tag <= BOUNDED
|| firstNatASTTreeTag <= tag && tag <= NAMEDARG
Expand All @@ -628,7 +630,7 @@ private[tasties] object TastyFormat:
case PRIVATE | PROTECTED | ABSTRACT | FINAL | SEALED | CASE | IMPLICIT | GIVEN | ERASED | LAZY | OVERRIDE | INLINE |
INLINEPROXY | MACRO | OPAQUE | STATIC | OBJECT | TRAIT | TRANSPARENT | INFIX | ENUM | LOCAL | SYNTHETIC |
ARTIFACT | MUTABLE | FIELDaccessor | CASEaccessor | COVARIANT | CONTRAVARIANT | HASDEFAULT | STABLE |
EXTENSION | PARAMsetter | PARAMalias | EXPORTED | OPEN | INVISIBLE | ANNOTATION | PRIVATEqualified |
EXTENSION | PARAMsetter | PARAMalias | EXPORTED | OPEN | INVISIBLE | INTO | ANNOTATION | PRIVATEqualified |
PROTECTEDqualified =>
true
case _ =>
Expand Down Expand Up @@ -687,6 +689,7 @@ private[tasties] object TastyFormat:
case PARAMalias => "PARAMalias"
case EMPTYCLAUSE => "EMPTYCLAUSE"
case SPLITCLAUSE => "SPLITCLAUSE"
case INTO => "INTO"

case SHAREDterm => "SHAREDterm"
case SHAREDtype => "SHAREDtype"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ private[tasties] class TreeUnpickler private (
case INVISIBLE => ignoreFlag()
case TRANSPARENT => addFlag(Transparent)
case INFIX => addFlag(Infix)
case INTO => addFlag(Into)
case PRIVATEqualified =>
ignoreFlag()
skipTree()
Expand Down
17 changes: 17 additions & 0 deletions tasty-query/shared/src/test/scala/tastyquery/ReadTreeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2411,4 +2411,21 @@ class ReadTreeSuite extends RestrictedUnpicklingSuite {
}
assert(containsSubtree(myMapStructure)(clue(myMapDef)))
}

testUnpickle("into-modifier", "simple_trees.IntoModifier") { tree =>
val intoClass: StructureCheck = {
case ClassDef(SimpleTypeName("IntoClass"), _, sym) if sym.isIntoType =>
}
assert(containsSubtree(intoClass)(clue(tree)))

val intoTrait: StructureCheck = {
case ClassDef(SimpleTypeName("IntoTrait"), _, sym) if sym.isIntoType =>
}
assert(containsSubtree(intoTrait)(clue(tree)))

val intoEnum: StructureCheck = {
case ClassDef(SimpleTypeName("IntoEnum"), _, sym) if sym.isIntoType =>
}
assert(containsSubtree(intoEnum)(clue(tree)))
}
}
15 changes: 15 additions & 0 deletions test-sources/src/main/scala/simple_trees/IntoModifier.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package simple_trees

import scala.Conversion.into

class IntoModifier {
def methodWithIntoString(x: into[String]): Unit = ()

into class IntoClass

into trait IntoTrait

into enum IntoEnum {
case Foo
}
}
Loading