Skip to content

Commit

Permalink
Make sure that .of returns a type
Browse files Browse the repository at this point in the history
Specifying a type object in a return constraint merely sets up a type
*check*, it does *not* actually return that type.  Fixes issue spotted
by b2gills++
  • Loading branch information
lizmat committed Mar 3, 2021
1 parent 7cdb4fb commit ee5244b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core.c/Array.pm6
Expand Up @@ -1277,7 +1277,7 @@ my class Array { # declared in BOOTSTRAP
}

proto method of() {*}
multi method of(Array:U: --> Mu) { }
multi method of(Array:U:) { Mu }
multi method of(Array:D:) {
nqp::isnull($!descriptor) ?? Mu !! $!descriptor.of
}
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Baggy.pm6
Expand Up @@ -12,7 +12,7 @@ my role Baggy does QuantHash {
# Immutables aspects of Bag/Mix, need to live to Bag/Mix respectively.

#--- interface methods
method of(--> UInt) { }
method of() { UInt }

multi method ACCEPTS(Baggy:U: \other --> Bool:D) {
other.^does(self)
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Block.pm6
Expand Up @@ -5,7 +5,7 @@ my class Block { # declared in BOOTSTRAP
# has Mu $!why;

proto method of() {*}
multi method of(Block:U: --> Mu) { }
multi method of(Block:U:) { Mu }
multi method of(Block:D:) { nqp::getattr(self,Code,'$!signature').returns }

method returns(Block:D:) { nqp::getattr(self,Code,'$!signature').returns }
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Hash.pm6
Expand Up @@ -210,7 +210,7 @@ my class Hash { # declared in BOOTSTRAP
method keyof() { Str(Any) } # overridden by Hash::Object

proto method of() {*}
multi method of(Hash:U: --> Mu) { }
multi method of(Hash:U:) { Mu }
multi method of(Hash:D:) { $!descriptor.of }

method name(Hash:D:) { $!descriptor.name }
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/IO/Path/Parts.pm6
Expand Up @@ -27,7 +27,7 @@ class IO::Path::Parts
# original List of Pairs / Map implementation. As soon as this is no longer
# needed, this can go.

method of(--> Str) { }
method of() { Str }

method iterator() { (:$!volume, :$!dirname, :$!basename).iterator }

Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Mixy.pm6
@@ -1,6 +1,6 @@
my role Mixy does Baggy {

method of(--> Real) { }
method of() { Real }

multi method hash(Mixy:D: --> Hash:D) { self!HASHIFY(Real) }
multi method Hash(Mixy:D: --> Hash:D) { self!HASHIFY(Any) }
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Scalar.pm6
Expand Up @@ -20,7 +20,7 @@ my class Scalar { # declared in BOOTSTRAP
}

proto method of() {*}
multi method of(Scalar:U: --> Mu) { }
multi method of(Scalar:U:) { Mu }
multi method of(Scalar:D:) {
nqp::isnull($!descriptor) ?? Mu !! $!descriptor.of
}
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/Setty.pm6
@@ -1,7 +1,7 @@
my role Setty does QuantHash {
has Rakudo::Internals::IterationSet $!elems; # key.WHICH => key

method of(--> Bool) { }
method of() { Bool }

# private method to create Set from iterator, check for laziness
method !create-from-iterator(\type, \iterator --> Setty:D) {
Expand Down

0 comments on commit ee5244b

Please sign in to comment.