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

A single name conflict between two libraries forces prefixes for all references to one of the libraries. #817

Closed
jacob314 opened this issue Dec 12, 2011 · 9 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P1 A high priority bug; for example, a single project is unusable or has many test failures type-enhancement A request for a change that isn't a bug
Milestone

Comments

@jacob314
Copy link
Member

A single name conflict between two libraries forces prefixes for all references to one of the libraries.

For example, user defined library contains a class named Point and dart:html contains a class named Point. Currently this has caused some users to abandon using dart:html altogether to avoid having to reference all types in dart:html with a prefixed name.
It would be better if only the conflicting names had to be prefixed rather than requiring all names to be prefixed.

@gbracha
Copy link
Contributor

gbracha commented Dec 12, 2011

We'll take a look and try and come up with something that works for people.


Added Accepted label.

@anders-sandholm
Copy link
Contributor

Removed this from the Release1.0 milestone.
Added this to the M1 milestone.

@gbracha
Copy link
Contributor

gbracha commented May 15, 2012

The show: and hide: combinators should solve this.


Added Done label.

@gbracha
Copy link
Contributor

gbracha commented Jun 8, 2012

Section 12.2 describes the show: and hide: combinators used to manipulate namespaces.

Implementation of these is tracke dby:

issue #3453 (VM)
issue #3454 (dart2js)
issue #3452 (analyzer)

@DartBot
Copy link

DartBot commented Jul 15, 2012

This comment was originally written by [email protected]


Show and hide seems quite cumbersome. Why not add the notation used in cascading as syntactic sugar so
#import('somelib.dart', show: ['foo', 'bar'])
can be written as
#import('somelib.dart..foo..bar')
which is shorter and a lot easier to remember

@gbracha
Copy link
Contributor

gbracha commented Jul 16, 2012

The syntax is changing. In any event, your proposal handles show but not hide. Nor will it scale to handle new combinators (say, rename) in the future.

@jacob314 jacob314 added Type-Enhancement P1 A high priority bug; for example, a single project is unusable or has many test failures area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Jul 16, 2012
@jacob314 jacob314 added this to the M1 milestone Jul 16, 2012
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
@goc20
Copy link

goc20 commented Dec 1, 2020

error: The name 'User' is defined in the libraries 'package:firebase_auth/firebase_auth.dart' and 'package:tunein/models/user.dart'. (ambiguous_import at [tunein] lib/resources/firebase_methods.dart:48)

I've defined user in user.dart but but it is defined in firebase_auth.dart please help I want to use it from 'user.dart'.

@goc20
Copy link

goc20 commented Dec 1, 2020

We'll take a look and try and come up with something that works for people.

Added Accepted label.

error: The name 'User' is defined in the libraries 'package:firebase_auth/firebase_auth.dart' and 'package:tunein/models/user.dart'. (ambiguous_import at [tunein] lib/resources/firebase_methods.dart:48)

I've defined user in user.dart but but it is defined in firebase_auth.dart please help I want to use it from 'user.dart'.

@eernstg
Copy link
Member

eernstg commented Dec 1, 2020

@goc20, check out section Using libraries, and in particular the subsection 'Importing only part of a library'.

import 'package:firebase_auth/firebase_auth.dart' hide User;
import 'package:firebase_auth/firebase_auth.dart' as firebase show User;
import 'package:tunein/models/user.dart';

void main() {
  firebase.User user1 = ...; // Declaration in firebase_auth.dart.
  User user2 = ...; // Declaration in user.dart.
}

copybara-service bot pushed a commit that referenced this issue Nov 27, 2023
…th, watcher

Revisions updated by `dart tools/rev_sdk_deps.dart`.

ecosystem (https://github.com/dart-lang/ecosystem/compare/dda7886..805ab4f):
  805ab4f  2023-11-22  Moritz  Add retries to `pub.dev/api/` calls (#199)
  4cc2cb4  2023-11-20  Devon Carew  add PR stats to the 'bin/report.dart weekly' command (#198)

matcher (https://github.com/dart-lang/matcher/compare/3d03fa1..fcbd361):
  fcbd361  2023-11-21  Nate Bosch  Add more advice away from predicate (#233)

native (https://github.com/dart-lang/native/compare/5dca10e..0051e78):
  0051e78d  2023-11-27  Hossein Yousefi  Generate getters for `static final` strings (#825)
  de505461  2023-11-27  Liam Appelbe  [ffigen] Update the ObjC and swift examples for the v10 code gen (#830)
  c371539d  2023-11-24  Simon Binder  ffigen: Don't generate setters for constant globals (#828)
  13b6b7e7  2023-11-24  Luke Rogers  Fixed a typo in the warn if private log message. (#824)
  9f29edc7  2023-11-21  Prerak Mann  [ffigen] Add config `ignore-source-errors`  (#810)
  6dc1c84c  2023-11-21  Hossein Yousefi  [infra] Add an issue template for jnigen (#820)
  3153a354  2023-11-21  Hossein Yousefi  [jnigen] Fix flaky tests (#814)
  8d4a241c  2023-11-21  Daco Harkes  [native_assets_cli] Add note to bump protocol version (#819)
  6c6a3d6c  2023-11-21  Daco Harkes  [infra] script to change deps to path dependencies (#817)
  893433ee  2023-11-20  Daco Harkes  [infra] Set `breaking-change` to false again (#816)
  992a563f  2023-11-20  Daco Harkes  [infra] Try to use `carryforward` (#815)
  7d9fbf38  2023-11-20  Daco Harkes  [infra] Try fix coveralls (#813)
  44861422  2023-11-20  Hossein Yousefi  [jnigen] Update links and paths to use dart-lang/native (#811)

protobuf (https://github.com/dart-lang/protobuf/compare/dcec2ed..cf43230):
  cf43230  2023-11-23  Ömer Sinan Ağacan  Update getList and getMap return types (#903)
  4e0bdff  2023-11-23  Ömer Sinan Ağacan  Make wrapped lists in PbList monomorphic (#902)

sse (https://github.com/dart-lang/sse/compare/0f6ca11..1df63f2):
  1df63f2  2023-11-21  Kevin Moore  Fix incorrect cast causing wasm failure, prepare v4.1.4 (#96)

test (https://github.com/dart-lang/test/compare/8ba0940..a0a4d1e):
  a0a4d1ee  2023-11-22  Kevin Moore  Update to latest version of lints (#2140)

vector_math (https://github.com/google/vector_math.dart/compare/294896d..e4066cc):
  e4066cc  2023-11-27  Lukas Klingsbo  Some general Vector4 optimizations (#295)
  d340ab0  2023-11-27  Lukas Klingsbo  Some general Vector3 optimizations (#294)
  571d3d0  2023-11-25  Lukas Klingsbo  fix: Revert Vector2 constructor changes (#304)

watcher (https://github.com/dart-lang/watcher/compare/b2b278a..6ac67f1):
  6ac67f1  2023-11-22  Danny Tuppeny  Enable file watcher tests on Windows (#156)

Change-Id: I0014566b05e852099bc4b82f854820e9d9992358
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338423
Commit-Queue: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P1 A high priority bug; for example, a single project is unusable or has many test failures type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants