Comments (1)
I don't nessaserilly agree with the assessment that this is removing an additional check - its simply erroring before you get to the check that you have in both.
If we break down the logic a bit more, in the first example this is trying to break down example into a tuple, and then attempting to pattern match inside of it.
In the second example, a and b do not exist unless you have already successfully run extractors on a Tuple2[Int, Int]
- which is going to fail.
Imagine a case where the inner extractor was not a simple type check, but passing through to some custom unapply method, which accepted only positive Ints, and ascii strings. In this hypothetical, the user in the first case would be asking "Do I have two fields which are either posative ints or ascii strings" and in the second is asking "Do I have exactly two posative ints".
We could also consider examples which were more complex than a simple tuple. For example class Foo[T](foo: Int | T)
. In this case an extractor of Foo[Int](a: int)
is clearly stronger than Foo(a:Int)
- and it would be up to the implementation of Foo.unapply
to determine how this further refinement was handled. In the case of case classes (and thus tuples) - unapply promises to preserve known types - and thus has to fail when the types is wrong.
If we wanted to make this work it would be opening up a whole heap of things in constructs like val Tuple2[Int,Int](a, b) = (???,???)
with a and b not getting the fully validated type.
from scala3.
Related Issues (20)
- Compiling standard library with `-experimental` causes AssertionError
- Incorrect "the type test for A cannot be checked at runtime because it's a local class" warning HOT 2
- java.lang.AssertionError: assertion failed: TS[753540, 753539, 753538] attempted to take ownership of B which is already owned by committable TS[808807, 753540, 753539, 753538] HOT 3
- Stabilise SIP 47 - Clause Interleaving
- Nightly Dotty workflow of 2024-06-25 failed
- Restore `BootstrappedOnlyCompilationTests.posWithCompilerCC` tests
- Outdated LazyVals reference in documentaiton
- Document migration steps for changed rules for given prioritisation under 3.6 HOT 1
- Scala 3 lazy vals are not serialization-safe HOT 8
- Regression in `alterationx10/opinionated-zio` match types HOT 1
- 3.5.0-RC2 regression: false positive unused warning on given import with wildcard HOT 1
- confusing treatment of context function literal HOT 7
- area:match-types Match type reduction stuck on disjointness test for types of the form `1 | Nothing`
- Context bounds types are not simplified in TASTy
- cannot be unpickled because no class file was found for denot: val <none>
- Nightly Dotty workflow of 2024-07-02 failed
- All `assert`s in `Quotes` should give helpful error messages
- Unexpected inferred union type with chained expressions HOT 5
- Missing unused warnings for lambdas parameters HOT 1
- Refinement with parent trait super call is refused when class is in a different package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala3.