Skip to content
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

SIP-56-extended: Refined provablyDisjoint test. #18416

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
62dda65
Update the perspective community build project to the latest upstream.
sjrd Aug 9, 2023
9f5aa6f
Update `perspective` to be compatible with the current state of `main`.
sjrd Aug 9, 2023
a377544
Introduce MatchTypeCaseSpec to categorize match type cases.
sjrd Jul 20, 2023
c61674b
Use new specced match types for class type constructors.
sjrd Aug 3, 2023
223be76
Use new specced match types for `scala.compiletime.int.S[n]`.
sjrd Aug 4, 2023
3f17d5a
Short-circuit match type cases with missing captures in their patterns.
sjrd Aug 4, 2023
628e50f
Use the specced match types for abstract tycons in patterns.
sjrd Aug 4, 2023
9c19ada
Make sure in CI that we do not unexpectedly fall back on legacy match…
sjrd Aug 7, 2023
048951c
Handle type member extractors as specced match types.
sjrd Aug 8, 2023
ccf7416
Introduce the SourceVersions 3.4 and 3.4-migration; make 3.4 the defa…
sjrd Aug 8, 2023
ff710e4
Disable legacy match types under source version >= 3.4.
sjrd Aug 8, 2023
bff2de6
Allow to reduce type member extractors when the member is a class.
sjrd Aug 14, 2023
aea28b9
Simplify the type member extractor logic.
sjrd Aug 15, 2023
12e74ac
SIP-56-extended: Simpler provablyDisjoint test.
sjrd Aug 17, 2023
a84fbb1
Use a `pending` set to detect infinite recursion.
sjrd Aug 28, 2023
4086ada
Remove disjointness of invariant type params based on isSameType.
sjrd Aug 28, 2023
f876971
Be more specific about higher-kinded types in provablyDisjoint.
sjrd Aug 29, 2023
cb94367
Do not use provablyEmpty anymore; use S <: T + provablyDisjoint(S, T)…
sjrd Aug 30, 2023
980c9e7
Add regression tests for old issues fixed with the new match types.
sjrd Aug 30, 2023
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
2 changes: 1 addition & 1 deletion community-build/community-projects/perspective
Submodule perspective updated 84 files
+47 −27 .scalafmt.conf
+27 −34 build.sbt
+26 −0 dotty/derivation/src/main/scala/perspective/derivation/ArrayProduct.scala
+252 −0 dotty/derivation/src/main/scala/perspective/derivation/Helpers.scala
+78 −0 dotty/derivation/src/main/scala/perspective/derivation/arrayProductK.scala
+363 −127 dotty/derivation/src/main/scala/perspective/derivation/hkdGeneric.scala
+1,102 −0 dotty/derivation/src/main/scala/perspective/derivation/inlineHkdGeneric.scala
+76 −38 dotty/derivation/src/main/scala/perspective/derivation/productK.scala
+172 −0 dotty/derivation/src/test/scala/perspective/derivation/CodecTests.scala
+161 −0 dotty/derivation/src/test/scala/perspective/derivation/HKDProductGenericTests.scala
+175 −0 dotty/derivation/src/test/scala/perspective/derivation/HKDSumGenericTests.scala
+45 −0 dotty/derivation/src/test/scala/perspective/derivation/HelpersTests.scala
+161 −0 dotty/derivation/src/test/scala/perspective/derivation/InlineCodecTests.scala
+327 −0 dotty/derivation/src/test/scala/perspective/derivation/InlineHKDProductGenericTests.scala
+358 −0 dotty/derivation/src/test/scala/perspective/derivation/InlineHKDSumGenericTests.scala
+58 −0 dotty/derivation/src/test/scala/perspective/derivation/InlineUnrollingCodecTests.scala
+78 −0 dotty/derivation/src/test/scala/perspective/derivation/ProductKTests.scala
+217 −65 dotty/examples/src/main/scala/perspective/examples/testing.scala
+11 −3 dotty/perspective/src/main/scala/perspective/ApplicativeK.scala
+17 −7 dotty/perspective/src/main/scala/perspective/ApplyK.scala
+11 −4 dotty/perspective/src/main/scala/perspective/Compose.scala
+7 −1 dotty/perspective/src/main/scala/perspective/Const.scala
+18 −10 dotty/perspective/src/main/scala/perspective/DistributiveK.scala
+26 −13 dotty/perspective/src/main/scala/perspective/Finite.scala
+12 −7 dotty/perspective/src/main/scala/perspective/FoldableK.scala
+54 −6 dotty/perspective/src/main/scala/perspective/FunctionK.scala
+19 −8 dotty/perspective/src/main/scala/perspective/FunctorK.scala
+2 −3 dotty/perspective/src/main/scala/perspective/Id.scala
+3 −3 dotty/perspective/src/main/scala/perspective/MonadK.scala
+27 −13 dotty/perspective/src/main/scala/perspective/RepresentableK.scala
+22 −8 dotty/perspective/src/main/scala/perspective/TraverseK.scala
+22 −7 dotty/perspective/src/main/scala/perspective/TupleK.scala
+8 −3 dotty/perspective/src/main/scala/perspective/ValueK.scala
+1 −1 project/build.properties
+2 −3 scala2/derivation/src/main/scala/perspective/derivation/ArrayProductK.scala
+77 −77 scala2/derivation/src/main/scala/perspective/derivation/ArrayProductKNewtypes.scala
+21 −8 scala2/derivation/src/main/scala/perspective/derivation/HKDProductGeneric.scala
+152 −23 scala2/derivation/src/main/scala/perspective/derivation/HKDProductGenericMacros.scala
+22 −13 scala2/derivation/src/main/scala/perspective/derivation/HKDSumGeneric.scala
+135 −8 scala2/derivation/src/main/scala/perspective/derivation/HKDSumGenericMacros.scala
+66 −52 scala2/derivation/src/main/scala/perspective/derivation/productK.scala
+1 −1 scala2/derivation/src/test/scala/perspective/derivation/DecoderDerive.scala
+37 −0 scala2/derivation/src/test/scala/perspective/derivation/DecoderDeriveFast.scala
+2 −2 scala2/derivation/src/test/scala/perspective/derivation/EncoderDerive.scala
+42 −0 scala2/derivation/src/test/scala/perspective/derivation/EncoderDeriveFast.scala
+6 −7 scala2/derivation/src/test/scala/perspective/derivation/GenericSpec.scala
+36 −0 scala2/derivation/src/test/scala/perspective/derivation/JsonFastSpec.scala
+4 −3 scala2/derivation/src/test/scala/perspective/derivation/JsonSpec.scala
+1 −1 scala2/examples/src/main/scala/perspective/examples/CodecDeriver.scala
+2 −2 scala2/examples/src/main/scala/perspective/examples/DecoderDerive.scala
+2 −2 scala2/examples/src/main/scala/perspective/examples/EncoderDerive.scala
+15 −11 scala2/examples/src/main/scala/perspective/examples/TestBig.scala
+9 −9 scala2/examples/src/main/scala/perspective/examples/testing.scala
+6 −4 scala2/macros/src/main/scala/perspective/macros/Derive.scala
+92 −98 scala2/macros/src/main/scala/perspective/macros/DeriveMacros.scala
+3 −4 scala2/macros/src/main/scala/perspective/macros/PerspectiveAnnotationMacros.scala
+2 −1 scala2/macros/src/main/scala/perspective/macros/hkd.scala
+0 −44 scala2/parameterized/src/main/scala/perspective/parameterized/Const.scala
+0 −29 scala2/parameterized/src/main/scala/perspective/parameterized/FunctionK.scala
+0 −17 scala2/parameterized/src/main/scala/perspective/parameterized/PApplicativeK.scala
+0 −14 scala2/parameterized/src/main/scala/perspective/parameterized/PApplyK.scala
+0 −22 scala2/parameterized/src/main/scala/perspective/parameterized/PFunctorK.scala
+0 −12 scala2/parameterized/src/main/scala/perspective/parameterized/PMonadK.scala
+0 −85 scala2/parameterized/src/main/scala/perspective/parameterized/package.scala
+1 −3 scala2/perspective/src/main/scala/perspective/ApplicativeK.scala
+1 −3 scala2/perspective/src/main/scala/perspective/ApplyK.scala
+1 −2 scala2/perspective/src/main/scala/perspective/DistributiveK.scala
+5 −2 scala2/perspective/src/main/scala/perspective/Finite.scala
+1 −3 scala2/perspective/src/main/scala/perspective/FoldableK.scala
+1 −3 scala2/perspective/src/main/scala/perspective/FunctorK.scala
+2 −4 scala2/perspective/src/main/scala/perspective/MonadK.scala
+2 −3 scala2/perspective/src/main/scala/perspective/RepresentableK.scala
+2 −3 scala2/perspective/src/main/scala/perspective/TraverseK.scala
+167 −71 scala2/perspective/src/main/scala/perspective/TupleInstances.scala
+3 −1 scala2/perspective/src/main/scala/perspective/package.scala
+1 −1 scala2/perspective/src/main/scala/perspective/syntax/ApplicativeKSyntax.scala
+11 −1 scala2/perspective/src/main/scala/perspective/syntax/ApplyKSyntax.scala
+3 −3 scala2/perspective/src/main/scala/perspective/syntax/DistributiveKSyntax.scala
+23 −3 scala2/perspective/src/main/scala/perspective/syntax/FoldableKSyntax.scala
+13 −1 scala2/perspective/src/main/scala/perspective/syntax/FunctorKSyntax.scala
+22 −3 scala2/perspective/src/main/scala/perspective/syntax/MonadKSyntax.scala
+15 −3 scala2/perspective/src/main/scala/perspective/syntax/RepresentableKSyntax.scala
+33 −3 scala2/perspective/src/main/scala/perspective/syntax/TraverseKSyntax.scala
+5 −3 scripts/makeArrayProductKNewtypes.sc
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum SourceVersion:
case `3.0-migration`, `3.0`, `3.1` // Note: do not add `3.1-migration` here, 3.1 is the same language as 3.0.
case `3.2-migration`, `3.2`
case `3.3-migration`, `3.3`
case `3.4-migration`, `3.4`
case `future-migration`, `future`

val isMigrating: Boolean = toString.endsWith("-migration")
Expand All @@ -21,7 +22,7 @@ enum SourceVersion:
def isAtMost(v: SourceVersion) = stable.ordinal <= v.ordinal

object SourceVersion extends Property.Key[SourceVersion]:
def defaultSourceVersion = `3.3`
def defaultSourceVersion = `3.4`

/** language versions that may appear in a language import, are deprecated, but not removed from the standard library. */
val illegalSourceVersionNames = List("3.1-migration").map(_.toTermName)
Expand Down
19 changes: 13 additions & 6 deletions compiler/src/dotty/tools/dotc/core/MatchTypeTrace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ object MatchTypeTrace:

private enum TraceEntry:
case TryReduce(scrut: Type)
case Stuck(scrut: Type, stuckCase: Type, otherCases: List[Type])
case NoInstance(scrut: Type, stuckCase: Type, fails: List[(Name, TypeBounds)])
case Stuck(scrut: Type, stuckCase: MatchTypeCaseSpec, otherCases: List[MatchTypeCaseSpec])
case NoInstance(scrut: Type, stuckCase: MatchTypeCaseSpec, fails: List[(Name, TypeBounds)])
case EmptyScrutinee(scrut: Type)
import TraceEntry._

Expand Down Expand Up @@ -54,10 +54,10 @@ object MatchTypeTrace:
* not disjoint from it either, which means that the remaining cases `otherCases`
* cannot be visited. Only the first failure is recorded.
*/
def stuck(scrut: Type, stuckCase: Type, otherCases: List[Type])(using Context) =
def stuck(scrut: Type, stuckCase: MatchTypeCaseSpec, otherCases: List[MatchTypeCaseSpec])(using Context) =
matchTypeFail(Stuck(scrut, stuckCase, otherCases))

def noInstance(scrut: Type, stuckCase: Type, fails: List[(Name, TypeBounds)])(using Context) =
def noInstance(scrut: Type, stuckCase: MatchTypeCaseSpec, fails: List[(Name, TypeBounds)])(using Context) =
matchTypeFail(NoInstance(scrut, stuckCase, fails))

/** Record a failure that scrutinee `scrut` is provably empty.
Expand All @@ -80,13 +80,16 @@ object MatchTypeTrace:
case _ =>
op

def caseText(spec: MatchTypeCaseSpec)(using Context): String =
caseText(spec.origMatchCase)

def caseText(tp: Type)(using Context): String = tp match
case tp: HKTypeLambda => caseText(tp.resultType)
case defn.MatchCase(any, body) if any eq defn.AnyType => i"case _ => $body"
case defn.MatchCase(pat, body) => i"case $pat => $body"
case _ => i"case $tp"

private def casesText(cases: List[Type])(using Context) =
private def casesText(cases: List[MatchTypeCaseSpec])(using Context) =
i"${cases.map(caseText)}%\n %"

private def explainEntry(entry: TraceEntry)(using Context): String = entry match
Expand Down Expand Up @@ -116,10 +119,14 @@ object MatchTypeTrace:
| ${fails.map((name, bounds) => i"$name$bounds")}%\n %"""

/** The failure message when the scrutinee `scrut` does not match any case in `cases`. */
def noMatchesText(scrut: Type, cases: List[Type])(using Context): String =
def noMatchesText(scrut: Type, cases: List[MatchTypeCaseSpec])(using Context): String =
i"""failed since selector $scrut
|matches none of the cases
|
| ${casesText(cases)}"""

def legacyPatternText(scrut: Type, cas: MatchTypeCaseSpec.LegacyPatMat)(using Context): String =
i"""Illegal match type because it contains the legacy, unspecifed case
| ${caseText(cas)}"""

end MatchTypeTrace
Loading