Skip to content

Commit

Permalink
[io grant] Fix .perl for IO::Path and subclasses
Browse files Browse the repository at this point in the history
Fixes RT#131185: https://rt.perl.org/Ticket/Display.html?id=131185

- Coercer doesn't take any named args; use .new() instead
- Always include $!CWD. Fixes failure to roundtrip Win32 paths that
    start with a slash
- Use right type for subclasses. Given them their own .perl, since
    they don't need to include $!SPEC
  • Loading branch information
zoffixznet committed May 1, 2017
1 parent 76af536 commit 134efd8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/IO/Path.pm
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ my class IO::Path is Cool does IO {
!! qq|"$.path".IO|
}
multi method perl(IO::Path:D:) {
$!is-absolute # attribute now set
?? "{$.absolute.perl}.IO({:$!SPEC.perl})"
!! "{$.path.perl}.IO({:$!SPEC.perl},{:$!CWD.perl})"
self.^name ~ ".new({$.path.perl}, {:$!SPEC.perl}, {:$!CWD.perl})"
}

method sibling(IO::Path:D: Str() \sibling) {
Expand Down Expand Up @@ -777,15 +775,27 @@ my class IO::Path is Cool does IO {

my class IO::Path::Cygwin is IO::Path {
method new(|c) { self.IO::Path::new(|c, :SPEC(IO::Spec::Cygwin) ) }
multi method perl(::?CLASS:D:) {
self.^name ~ ".new({$.path.perl}, {:$.CWD.perl})"
}
}
my class IO::Path::QNX is IO::Path {
method new(|c) { self.IO::Path::new(|c, :SPEC(IO::Spec::QNX) ) }
multi method perl(::?CLASS:D:) {
self.^name ~ ".new({$.path.perl}, {:$.CWD.perl})"
}
}
my class IO::Path::Unix is IO::Path {
method new(|c) { self.IO::Path::new(|c, :SPEC(IO::Spec::Unix) ) }
multi method perl(::?CLASS:D:) {
self.^name ~ ".new({$.path.perl}, {:$.CWD.perl})"
}
}
my class IO::Path::Win32 is IO::Path {
method new(|c) { self.IO::Path::new(|c, :SPEC(IO::Spec::Win32) ) }
multi method perl(::?CLASS:D:) {
self.^name ~ ".new({$.path.perl}, {:$.CWD.perl})"
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 134efd8

Please sign in to comment.